﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Web.UI;
namespace TA.Turbo.Controls
{
	/// <summary>
	/// Collection of <see cref="PostScenario"/>s.
	/// </summary>
	public class ScenarioCollection : ControlCollection<PostScenario>
	{
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="owner"></param>
		public ScenarioCollection(Control owner) : base(owner) { }
		/// <summary>
		/// Adds the scenario to <see cref="TPage.AllScenarios"/> collection.
		/// </summary>
		/// <param name="item"></param>
		protected override void OnItemAdded(PostScenario item)
		{
			base.OnItemAdded(item);
			//if(this.Ow
			if (TPage.Current != null)
				TPage.Current.AllScenarios.Add(item);
		}
		/// <summary>
		/// Removes the scenario from <see cref="TPage.AllScenarios"/> collection.
		/// </summary>
		/// <param name="item"></param>
		protected override void OnItemRemoved(PostScenario item)
		{
			base.OnItemRemoved(item);
			if (TPage.Current != null)
				TPage.Current.AllScenarios.Remove(item);
		}
	}
}